import math
import matplotlib.pyplot as plt

def LoadArray(path):
    with open(path, 'r') as f:
        return [float(x) for x in f.read().split()]

def WarpCol(v, nCol):
    m=[]
    for i in range(0, len(v), nCol):
        m.append([])
        for j in range(0, nCol):
            m[i/nCol].append(v[i+j])
    return m

def GetCol(m, iCol):
    c=[]
    for i in range(0, len(m)):
        c.append(m[i][iCol])
    return c


dfx=1
ic=5

folder="/media/u/5E16B36816B33FB7/tl1/"

a=LoadArray(folder+"746112061911_2ZuA6Ug8/istamp.txt")
b=LoadArray(folder+"802212060443_Swmnxa3B/istamp.txt")


am=WarpCol(a,7)
bm=WarpCol(b,7)

ax=GetCol(am, 1)
ay1=GetCol(am, ic)
    
bx=GetCol(bm, 1)
by1=GetCol(bm, ic)

x=[]
y=[]

for i in range(0, len(bx)):
	for j in range(0, len(ax)):
		if bx[i]+dfx==ax[j]:
			x.append(ax[j])
			y.append(ay1[j]-by1[i])
			break
		
print(x)
print(y)	

print([min(y), max(y)])

plt.plot(x, y, '.b')
#plt.axis('equal')
title='nA-nB='+str(dfx)
plt.xlabel('nA')
plt.ylabel('tA-tB['+str(ic)+']')
plt.title(title)
plt.grid(True)
plt.savefig(folder+'istamp'+str(ic)+'.png')
#plt.show()




